import pytest
from page_object.base_page import LocalChromeDriver, RemoteChromeDriver
from page_object.home import Home


def pytest_addoption(parser):
    parser.addoption(
        "--browser",
        action="store",
        default="local_chrome",
        help="Select browser chrome or firefox",
    )


@pytest.fixture(scope="session")
def browser(request):
    return request.config.getoption("--browser")


browsers = {
    "local_chrome": LocalChromeDriver,
    "remote_chrome": RemoteChromeDriver,
}


@pytest.fixture(scope="session")
def home(browser):
    print(f"{browser=}")
    driver = browsers[browser]().driver
    home = Home(url="https://work.weixin.qq.com/", driver=driver)

    yield home

    driver.close()
